package leetcode.code2079;

import leetcode.IDebug;
import leetcode.helper.HelpDebug;

public class Solution implements IDebug {

	public int wateringPlants(int[] plants, int capacity) {
		int ans = 0;
		int len = plants.length;
		int water = capacity;
		for (int i = 0; i < len; i++) {
			int cur = plants[i];
			if (water >= cur) {
				ans += 1;
				water -= cur;
			} else {
				// [2,2,3,3]
				ans += 1 + (i << 1);
				water = capacity - cur;
			}
		}
		return ans;
	}

	@Override
	public void debug1() {
		HelpDebug.compare(14, this.wateringPlants(HelpDebug.str2array3("[2,2,3,3]"), 5));

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
